package com.example.nit.listener;

import com.example.nit.whole.Reference;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.annotation.TopicPartition;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Component
public class SparkStreaming4Listener {



     public List<String> list=new ArrayList<>();


    @KafkaListener(id = "consumer1", groupId = "niit02",topicPartitions = {
            @TopicPartition(topic = "task4",partitions = "0")
    })
    public List<String>  task4(List<ConsumerRecord<?, ?>> records) {
        for (ConsumerRecord<?, ?> record : records) {

            list.add((String) record.value());
        }
        System.out.println(list);
        Reference.CurrentList =  list;
        return list;

    }



}
